﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using seo.Data;
using seo.DAO;
using seo.dbutils;

namespace seo.Buz
{
    public class WebSiteBuz
    {
        public List<Website> getAllKeyword()
        {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            List<Website> list = null;
            try
            {
                conn.Open();
                WebsiteDao dao = new WebsiteDao(conn);
                list = dao.getAllWebsite();
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return list;

        }

        public Website getWebsiteById(int id)
        {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            Website website = null;
            try
            {
                conn.Open();
                WebsiteDao dao = new WebsiteDao(conn);
                website = dao.getWebsiteById(id);
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return website;

        }

        public List<Website> getWebsiteByBelongGroup(string belongGroup)
        {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            List<Website> list = null;
            conn.Open();
            try
            {
                WebsiteDao dao = new WebsiteDao(conn);
                list = dao.getWebsiteByBelongGroup(belongGroup);
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return list;

        }

        public int getTotalImpValue(string belongGroup)
        {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            int totalImpValue = 0;
            try
            {
                conn.Open();
                WebsiteDao dao = new WebsiteDao(conn);
                totalImpValue = dao.getTotalImpValue(belongGroup);
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return totalImpValue;

        }
    }
}
